import {createMemoryHistory, createRouter, createWebHashHistory, createWebHistory} from 'vue-router'
import {constantRouter} from "@/router/router";

let router: any;

if (typeof window !== 'undefined') {
    // 在浏览器环境中使用浏览器历史记录模式或哈希模式
    router = createRouter({
        //@ts-ignore
        history: createWebHistory(),
        routes: constantRouter,
        scrollBehavior(to, from, savedPosition) {
            return {left: 0, top: 0};
        }
    })
} else {
    // 在非浏览器环境中进行适配或使用其他路由解决方案
    router = createRouter({
        //@ts-ignore
        history: createMemoryHistory(),
        routes: constantRouter,
        scrollBehavior(to, from, savedPosition) {
            return {left: 0, top: 0};
        }
    })
}


export default router
